package com.anolesoft.twelvePlan.service.impl;

import com.anolesoft.twelvePlan.dto.GongDuanPlanDTO;
import com.anolesoft.twelvePlan.dto.GongDuanPlanExport;
import com.anolesoft.twelvePlan.mapper.MesPlanXiaDaMapper;
import com.anolesoft.twelvePlan.service.GongDuanPlanService;
import com.anolesoft.yr.util.PageData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zyq
 * @date 2022/3/30
 */
@Service
@Slf4j
public class GongDuanPlanServiceImpl implements GongDuanPlanService {

    @Autowired
    private MesPlanXiaDaMapper mesPlanXiaDaMapper;

    @Override
    public PageData<List<GongDuanPlanDTO>> queryGDPlan(GongDuanPlanDTO gongDuanPlanDTO, Integer pageNo, Integer pageSize) {
        Page<GongDuanPlanDTO> page = new Page<>(pageNo, pageSize);
        List<GongDuanPlanDTO> gongDuanPlanDTOList = this.mesPlanXiaDaMapper.queryGDPlan(gongDuanPlanDTO, page);
        return new PageData<>(((int) page.getTotal()), gongDuanPlanDTOList);
    }

    @Override
    public PageData<List<GongDuanPlanExport>> exportGDPlan(GongDuanPlanDTO gongDuanPlanDTO, Integer pageNo, Integer pageSize) {
        Page<GongDuanPlanExport> page = new Page<>(pageNo,pageSize);
        List<GongDuanPlanExport> gongDuanPlanExports = this.mesPlanXiaDaMapper.exportGDPlan(gongDuanPlanDTO, page);
        return new PageData<>(((int) page.getTotal()), gongDuanPlanExports);
    }
}
